default: all
include Makefile.config

BASE_DIRS =\
 base\
 matrix

SOLVE_DIRS =\
 solvers

DIRS =\
 ${BASE_DIRS}\
 ${SOLVE_DIRS}
#################################################################
# Targets
#################################################################

all:
	@ \
	mkdir -p ${INSTALL_DIR}/include; \
	mkdir -p ${INSTALL_DIR}/lib; \
	touch combine.mri; \
	echo "create ${INSTALL_DIR}/lib/libUNAP.a">>combine.mri; \
	for i in ${DIRS}; \
	do \
	  echo "Making $$i ..."; \
	  (cd $$i && $(MAKE) $@) || exit 1; \
	  echo "addlib $$i/libUNAP_$$i.a">>combine.mri; \
	  echo ""; \
	done
	echo "save">>combine.mri
	echo "end">>combine.mri
	echo "Installing ..."
	ar -M < combine.mri
	rm combine.mri



clean:
	@ \
	rm -Rf ${INSTALL_DIR}; \
	for i in ${DIRS}; \
	do \
	  if [ -f $$i/Makefile ]; \
	  then \
	    echo "Cleaning $$i ..."; \
	    (cd $$i && $(MAKE) $@) || exit 1; \
	  fi; \
	done
